home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / System / SYMBOL / Symbol Generators / L-System / transform-lsystem < prev   
Lisp/Scheme  |  1998-10-23  |  3KB  |  78 lines

  1. transform-lsystem symbol-pattern
  2.  
  3. Transforms the output generated by gen-rewrite to a symbol pattern using + - < > as special operators to control the transposing and stack operations. The interpretation of different symbols in a symbol-pattern is done according to the following table.
  4.  
  5.  + adds transpose value by 1
  6.  - subtracts transpose by 1
  7.  < pushes transpose value on stack
  8.  > pops value from stack
  9.  
  10. Any other symbol is transformed by the current transpose value.
  11.  
  12. The stack operators < and > can be used several ways to control the generation process. Also any production rules can be used since they can be filtered out by filter-preserve.
  13.  
  14. (initdef)
  15. (defsym g '(g f x < + g > < - g >))
  16. (defsym x '(x < - f f f > < + f f f > f x))
  17. (defsym - '-)
  18. (defsym + '+)
  19. (defsym < '<)
  20. (defsym > '>)
  21.  
  22. (setq product (gen-rewrite g 2))
  23. --> (g f x < + g > < - g > x < - f f f > < + f f f > f x 
  24.  < + g f x < + g > < - g > > < - g f x < + g > < - g > >)
  25.  
  26. (transform-lsystem (filter-preserve product '(f + - < >)))
  27. --> (f e e e g g g f g e)
  28.  
  29. A shorter way to activate the whole process is to use gen-lsystem function. It generates the raw material, cleans it up and transforms it into symbols, and returns a symbol pattern. If gen-lsystem is activated without the special preserve list, generations are transformed as they are.
  30.  
  31. (gen-lsystem g 2 '(f + - < >))
  32. --> (f e e e g g g f g e)
  33.  
  34. Numeric Stack Control
  35.  
  36. You can also control how much transpositions will occur in the stack by placing a value just before the minus or plus sign. This case you can also use times and divide operations. Note that the number must be written without spaces to the following sign.
  37.  
  38. Example
  39.  
  40. This example is the same as above and shows you how you should write the defsys symbols when using stack control. All 1+, 2+ etc symbols you are using must be explicitely defined by defsym.
  41.  
  42. (initdef)
  43. (defsym g '(g f x < 1+ g > < 1- g >))
  44. (defsym x '(x < 1- f f f > < 1+ f f f > f x))
  45. (defsym - '-)
  46. (defsym + '+)
  47. (defsym < '<)
  48. (defsym > '>)
  49. (defsym 1+ '1+)
  50. (defsym 1- '1-)
  51.  
  52. (setq product (gen-rewrite g 2))
  53. --> (g f x < + g > < - g > x < - f f f > < + f f f > f x < + 
  54.  g f x < + g > < - g > > < - g f x < + g > < - g > >)
  55.  
  56. (transform-lsystem (filter-preserve product '(f + - < > 1- 1+)))
  57. --> (f e e e g g g f g e)
  58.  
  59. Another Example
  60.  
  61. (initdef)
  62. (defsym g '(g f x < 1.5+ g > < 2.2- g >))
  63. (defsym x '(x < 4.4- f f f > < 3.7+ f f f > f x))
  64. (defsym - '-)
  65. (defsym + '+)
  66. (defsym < '<)
  67. (defsym > '>)
  68. (defsym 1.5+ '1.5+)
  69. (defsym 2.2- '2.2-)
  70. (defsym 4.4- '4.4-)
  71. (defsym 3.7+ '3.7+)
  72.  
  73. (setq product (gen-rewrite g 2))
  74.  
  75. (transform-lsystem (filter-preserve product '(f + - < > 1.5+ 2.2- 4.4- 3.7+)))
  76. --> (f b b b j j j f h d)
  77.  
  78.